﻿Imports System.Drawing

Public Class Style

    Public Enum EFade
        None
        Fade
        CrossFade
    End Enum

    Public Enum EBackgroundType
        None
        SolidColour
        Image
        Video
        LiveFeed
    End Enum

    ''' <summary>
    ''' The position of text within a bounding box (ie: projectlet).
    ''' </summary>
    Public Enum ETextAlignment

        ''' <summary>
        ''' Text is aligned at the top left position.
        ''' </summary>
        TopLeft

        ''' <summary>
        ''' Text is aligned at the centre of the top position.
        ''' </summary>
        TopMiddle

        ''' <summary>
        ''' Text is aligned at the top right position.
        ''' </summary>
        TopRight

        ''' <summary>
        ''' Text is aligned at the left position in the middle.
        ''' </summary>
        MiddleLeft

        ''' <summary>
        ''' Text is aligned at the centre, both horizontally and vertically.
        ''' </summary>
        MiddleMiddle

        ''' <summary>
        ''' Text is aligned at the right position in the middle.
        ''' </summary>
        MiddleRight

        ''' <summary>
        ''' Text is aligned at the bottom left position.
        ''' </summary>
        BottomLeft

        ''' <summary>
        ''' Text is aligned in the centre of the bottom position.
        ''' </summary>
        BottomMiddle

        ''' <summary>
        ''' Text is aligned at the bottom right position.
        ''' </summary>
        BottomRight

    End Enum

    Public Enum ETextEffect
        None
        InnerOutline
        Shadow
        OutlineBox
        FilledBox
        Outline
    End Enum

    ''' <summary>
    ''' Indicates when the item is displayed.
    ''' </summary>
    Public Enum EDisplayOption

        ''' <summary>
        ''' The item is displayed at all times.
        ''' </summary>
        Always

        ''' <summary>
        ''' The item is never displayed.
        ''' </summary>
        Never

        ''' <summary>
        ''' The item is displayed only on the first verse, and only once.
        ''' </summary>
        FirstVerseOnce

        ''' <summary>
        ''' The item is displayed only on the first verse.
        ''' </summary>
        FirstVerse

        ''' <summary>
        ''' The item is displayed only on the second verse, and only once.
        ''' </summary>
        SecondVerseOnce

        ''' <summary>
        ''' The item is displayed only on the second verse.
        ''' </summary>
        SecondVerse

        ''' <summary>
        ''' The item is displayed only on the last verse, and only once.
        ''' </summary>
        LastVerseOnce

        ''' <summary>
        ''' The item is displayed only on the last verse.
        ''' </summary>
        LastVerse

    End Enum

    Private FStyleID As Guid = Nothing

    Public Property StyleID() As Guid
        Get
            If FStyleID = Nothing Then Throw New ApplicationException("No ID has been set for this style.")
            Return FStyleID
        End Get
        Set(ByVal value As Guid)
            If FStyleID <> Nothing Then Throw New ApplicationException("An ID has already been set for this style.")
            FStyleID = value
        End Set
    End Property

    Public Property Name() As String = "Unnamed Style"

    Public Property DefaultBackgroundImage() As String = String.Empty

    Public Property DefaultBackgroundColour() As Color = Color.DarkBlue

    Public Property BackgroundType() As EBackgroundType = EBackgroundType.SolidColour
    
    Public Property GeneralFade() As EFade = Style.EFade.Fade

    Public Property GeneralFadeDuration() As Integer = 20

    Public Property VerseFade() As EFade = Style.EFade.CrossFade

    Public Property VerseFadeDuration() As Integer = 5

    Private FProjectlets As New List(Of ProjectletStyle)

    Public ReadOnly Property Projectlets() As List(Of ProjectletStyle)
        Get
            Return FProjectlets
        End Get
    End Property

    Default Public ReadOnly Property ProjectletsByName(ByVal category As String) As ProjectletStyle
        Get
            For Each Item As ProjectletStyle In FProjectlets
                If Item.Category = category Then Return Item
            Next
            Throw New ApplicationException("Projectlet category '" + category + "' not found.")
        End Get
    End Property

    ''' <summary>
    ''' Initializes a new instance of the <see cref="Style" /> class.
    ''' </summary>
    ''' <param name="name">The name of the style.</param>
    Public Sub New(ByVal name As String)

        Me.Name = name

        ' Initialise default projectlets
        Dim Title As New ProjectletStyle("Title")
        Title.Alignment = ETextAlignment.TopMiddle
        Title.Area = New RectangleF(0.05, 0.05, 0.9, 0.15)
        Title.DisplayOption = EDisplayOption.FirstVerseOnce
        Title.FontEffect = ETextEffect.None
        Title.FontColour = Color.Silver
        Title.FontStyle = FontStyle.Bold
        Title.Content = ProjectletStyle.TITLE_TAG
        FProjectlets.Add(Title)

        Dim Verse As New ProjectletStyle("Verse")
        Verse.Alignment = ETextAlignment.MiddleMiddle
        Verse.Area = New RectangleF(0.05, 0.15, 0.9, 0.8)
        Verse.DisplayOption = EDisplayOption.Always
        Verse.FontEffect = ETextEffect.Shadow
        Verse.FontColour = Color.White
        Verse.FontEffectColour = Color.Black
        Verse.Content = ProjectletStyle.VERSE_TAG
        FProjectlets.Add(Verse)

        Dim Copyright As New ProjectletStyle("Copyright")
        Copyright.Alignment = ETextAlignment.BottomMiddle
        Copyright.Area = New RectangleF(0.05, 0.95, 0.9, 0.05)
        Copyright.DisplayOption = EDisplayOption.LastVerseOnce
        Copyright.FontEffect = ETextEffect.None
        Copyright.FontColour = Color.Silver
        Copyright.FontSize = 30
        Copyright.FontStyle = FontStyle.Italic
        Copyright.Content = ProjectletStyle.SIMPLE_COPYRIGHT_TAG
        FProjectlets.Add(Copyright)

    End Sub

End Class
